//
//  DemoViewController.swift
//  WB_Swift3.0
//
//  Created by wangrui on 2017/3/13.
//  Copyright © 2017年 wangrui. All rights reserved.
//

import UIKit

class DemoViewController: BaseViewController
{
    override func viewDidLoad()
    {
        super.viewDidLoad()
        navItem.title = "第\(navigationController?.childViewControllers.count ?? 0)个"
    }
    
    @objc fileprivate func clickNext()
    {
        let vc = DemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
    @objc fileprivate func goBack()
    {
        _ = navigationController?.popViewController(animated: true)
    }
}


extension DemoViewController
{
    override func setupTableView()
    {
        super.setupTableView()
        navItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", target: self, action: #selector(clickNext))
        var title = "返回"
        if navigationController?.childViewControllers.count == 2 {
            title = navigationController?.childViewControllers[0].title ?? "返回"
        }
        navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(goBack), isBack:true)
    }
}
